Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 29, 2025

  • Analyze the issue: Need to extract domain names from metadata addresses for telemetry
  • Explore the repository structure and identify relevant files
  • Understand current telemetry implementation in TelemetryClient.cs
  • Restore and build the solution successfully
  • Add AppContext switch for backward compatibility
  • Create utility method to extract domain name from metadata address
  • Update TelemetryClient to use domain name only in success cases
  • Create comprehensive tests to validate the new functionality
  • Fix test method logic to properly extract domain names
  • Validate implementation works as expected
  • Test the implementation with complete test suite
  • Verify error cases continue using full address as specified
  • Address performance concern - removed www. prefix stripping operation
  • Fix AppContext switch test interference issues

Implementation Complete ✅

Successfully implemented the telemetry domain extraction feature and addressed all feedback:

Feedback Addressed:

  1. @GeoK's Performance Comment: Removed the www. prefix stripping operation to improve hot path performance (already addressed in commit e36a9b9)

  2. @westin-m's Test Interference: Fixed AppContext switch interference by adding [ResetAppContextSwitches] attribute to the test class for proper test isolation

Key Features:

  • Domain Extraction: Extracts domain names from metadata URLs (e.g., "login.microsoftonline.com" from full URL)
  • Performance Optimized: No unnecessary string operations on hot path
  • Error Case Protection: Always uses full addresses for error cases to maintain debugging capabilities
  • Backward Compatibility: AppContext switch for reverting to full addresses
  • Test Isolation: Proper test isolation to prevent AppContext switch interference
  • Comprehensive Testing: 17 test cases covering all scenarios

The implementation reduces OpenTelemetry cardinality while maintaining backward compatibility and performance.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature Request] Use domain name only for IdentityModelConfiguration* metrics instead of full metadata address</issue_title>
<issue_description>Some services utilize numerous metadata addresses that exceed OpenTelemetry cardinality limits. To address this, IdentityModel should capture only the domain name rather than the complete metadata address, in success cases.

Example:

Instead of reporting https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration, report only microsoftonline.com

Since this represents a breaking behavioral change, IdentityModel should provide an AppContext switch to allow reverting to the previous behavior.</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #3302

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] [Feature Request] Use domain name only for IdentityModelConfiguration* metrics instead of full metadata address Use domain name only for telemetry metadata addresses to reduce OpenTelemetry cardinality Sep 29, 2025
Copilot AI requested a review from westin-m September 29, 2025 21:49
Copilot finished work on behalf of westin-m September 29, 2025 21:49
@westin-m westin-m marked this pull request as ready for review September 30, 2025 17:28
@westin-m westin-m requested a review from a team as a code owner September 30, 2025 17:28
@westin-m
Copy link
Contributor

@copilot there are test failures that look to be caused by AppContext switch interference. Please address this

Copy link
Contributor Author

Copilot AI commented Sep 30, 2025

@copilot there are test failures that look to be caused by AppContext switch interference. Please address this

Fixed the AppContext switch test interference by adding the [ResetAppContextSwitches] attribute to the test class. This provides proper test isolation and prevents switches from affecting other tests. All telemetry tests now pass successfully in commit a7d8842.

Copilot finished work on behalf of westin-m September 30, 2025 22:57
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test kept failing when ran alongside the new ones introduced by this PR. Putting them in the same collection was the most minimal and only effective solution I found.

@github-actions

This comment was marked as outdated.

@github-actions
Copy link

github-actions bot commented Oct 7, 2025

Summary

Summary
Generated on: 10/7/2025 - 10:02:18 PM
Coverage date: 10/7/2025 - 9:54:06 PM - 10/7/2025 - 10:01:34 PM
Parser: MultiReport (60x Cobertura)
Assemblies: 1
Classes: 7
Files: 2
Line coverage: 80.3% (620 of 772)
Covered lines: 620
Uncovered lines: 152
Coverable lines: 772
Total lines: 483
Branch coverage: 67.8% (228 of 336)
Covered branches: 228
Total branches: 336
Method coverage: Feature is only available for sponsors

Coverage

Microsoft.IdentityModel.JsonWebTokens - 80.3%
Name Line Branch
Microsoft.IdentityModel.JsonWebTokens 80.3% 67.8%
Microsoft.IdentityModel.JsonWebTokens.JwtTokenUtilities 100%
System.Text.RegularExpressions.Generated 80.3% 67.8%
System.Text.RegularExpressions.Generated 80.3% 67.8%
System.Text.RegularExpressions.Generated.<RegexGenerator_g>F12A1AEDDDFE32BA
DF4DBFF323AF1BCB48B9F9721B7CD3E05F5E034CF225E3DF8__CreateJweRegex_1
79.2% 68%
System.Text.RegularExpressions.Generated.<RegexGenerator_g>F12A1AEDDDFE32BA
DF4DBFF323AF1BCB48B9F9721B7CD3E05F5E034CF225E3DF8__CreateJwsRegex_0
81.4% 67.6%
System.Text.RegularExpressions.Generated.<RegexGenerator_g>F334844C618E00D3
CEC5D3FE0D00CF0141BBEE98635313BB2CB8D3921464CE05A__CreateJweRegex_1
79.2% 68%
System.Text.RegularExpressions.Generated.<RegexGenerator_g>F334844C618E00D3
CEC5D3FE0D00CF0141BBEE98635313BB2CB8D3921464CE05A__CreateJwsRegex_0
81.4% 67.6%

@github-actions
Copy link

github-actions bot commented Oct 8, 2025

Summary

Summary
Generated on: 10/8/2025 - 6:17:10 PM
Coverage date: 10/8/2025 - 6:08:28 PM - 10/8/2025 - 6:16:28 PM
Parser: MultiReport (60x Cobertura)
Assemblies: 1
Classes: 7
Files: 2
Line coverage: 80.3% (620 of 772)
Covered lines: 620
Uncovered lines: 152
Coverable lines: 772
Total lines: 483
Branch coverage: 67.8% (228 of 336)
Covered branches: 228
Total branches: 336
Method coverage: Feature is only available for sponsors

Coverage

Microsoft.IdentityModel.JsonWebTokens - 80.3%
Name Line Branch
Microsoft.IdentityModel.JsonWebTokens 80.3% 67.8%
Microsoft.IdentityModel.JsonWebTokens.JwtTokenUtilities 100%
System.Text.RegularExpressions.Generated 80.3% 67.8%
System.Text.RegularExpressions.Generated 80.3% 67.8%
System.Text.RegularExpressions.Generated.<RegexGenerator_g>F12A1AEDDDFE32BA
DF4DBFF323AF1BCB48B9F9721B7CD3E05F5E034CF225E3DF8__CreateJweRegex_1
79.2% 68%
System.Text.RegularExpressions.Generated.<RegexGenerator_g>F12A1AEDDDFE32BA
DF4DBFF323AF1BCB48B9F9721B7CD3E05F5E034CF225E3DF8__CreateJwsRegex_0
81.4% 67.6%
System.Text.RegularExpressions.Generated.<RegexGenerator_g>F334844C618E00D3
CEC5D3FE0D00CF0141BBEE98635313BB2CB8D3921464CE05A__CreateJweRegex_1
79.2% 68%
System.Text.RegularExpressions.Generated.<RegexGenerator_g>F334844C618E00D3
CEC5D3FE0D00CF0141BBEE98635313BB2CB8D3921464CE05A__CreateJwsRegex_0
81.4% 67.6%

@westin-m westin-m requested review from GeoK and keegan-caruso October 9, 2025 19:35
@github-actions
Copy link

github-actions bot commented Oct 9, 2025

Summary

Summary
Generated on: 10/9/2025 - 8:40:26 PM
Coverage date: 10/9/2025 - 8:31:23 PM - 10/9/2025 - 8:39:43 PM
Parser: MultiReport (60x Cobertura)
Assemblies: 1
Classes: 7
Files: 2
Line coverage: 80.3% (620 of 772)
Covered lines: 620
Uncovered lines: 152
Coverable lines: 772
Total lines: 483
Branch coverage: 67.8% (228 of 336)
Covered branches: 228
Total branches: 336
Method coverage: Feature is only available for sponsors

Coverage

Microsoft.IdentityModel.JsonWebTokens - 80.3%
Name Line Branch
Microsoft.IdentityModel.JsonWebTokens 80.3% 67.8%
Microsoft.IdentityModel.JsonWebTokens.JwtTokenUtilities 100%
System.Text.RegularExpressions.Generated 80.3% 67.8%
System.Text.RegularExpressions.Generated 80.3% 67.8%
System.Text.RegularExpressions.Generated.<RegexGenerator_g>F12A1AEDDDFE32BA
DF4DBFF323AF1BCB48B9F9721B7CD3E05F5E034CF225E3DF8__CreateJweRegex_1
79.2% 68%
System.Text.RegularExpressions.Generated.<RegexGenerator_g>F12A1AEDDDFE32BA
DF4DBFF323AF1BCB48B9F9721B7CD3E05F5E034CF225E3DF8__CreateJwsRegex_0
81.4% 67.6%
System.Text.RegularExpressions.Generated.<RegexGenerator_g>F334844C618E00D3
CEC5D3FE0D00CF0141BBEE98635313BB2CB8D3921464CE05A__CreateJweRegex_1
79.2% 68%
System.Text.RegularExpressions.Generated.<RegexGenerator_g>F334844C618E00D3
CEC5D3FE0D00CF0141BBEE98635313BB2CB8D3921464CE05A__CreateJwsRegex_0
81.4% 67.6%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Use domain name only for IdentityModelConfiguration* metrics instead of full metadata address

4 participants